home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Magazine / Morphos / GCC / lib / gcc-lib / ppc-amigaos / 2.95.1 / include / va-m32r.h < prev    next >
C/C++ Source or Header  |  2000-03-13  |  2KB  |  87 lines

  1. /* GNU C stdarg/varargs support for the M32R */
  2.  
  3. /* Define __gnuc_va_list.  */
  4. #ifndef __GNUC_VA_LIST
  5. #define __GNUC_VA_LIST
  6. typedef void *__gnuc_va_list;
  7. #endif /* not __GNUC_VA_LIST */
  8.  
  9. /* If this is for internal libc use, don't define anything but
  10.    __gnuc_va_list.  */
  11. #if defined (_STDARG_H) || defined (_VARARGS_H)
  12.  
  13. /* Common code for va_start for both varargs and stdarg.  */
  14.  
  15. #define __va_rounded_size(TYPE)  \
  16.   (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
  17.  
  18. #ifdef _STDARG_H /* stdarg.h support */
  19.  
  20. /* Calling __builtin_next_arg gives the proper error message if LASTARG is
  21.    not indeed the last argument.  */
  22. #define va_start(AP, LASTARG)                         \
  23.  (AP = ((__gnuc_va_list) __builtin_next_arg (LASTARG)))
  24.  
  25. #else /* varargs.h support */
  26.  
  27. #define va_alist  __builtin_va_alist
  28. /* The ... causes current_function_varargs to be set in cc1.  */
  29. #define va_dcl    int __builtin_va_alist; ...
  30. #define va_start(AP)  AP=(char *) &__builtin_va_alist
  31.  
  32. #endif /* _STDARG_H */
  33.  
  34. /* Nothing needs to be done to end varargs/stdarg processing */
  35. #define va_end(AP) ((void) 0)
  36.  
  37. /* Values returned by __builtin_classify_type.  */
  38. enum __type_class
  39. {
  40.   __no_type_class = -1,
  41.   __void_type_class,
  42.   __integer_type_class,
  43.   __char_type_class,
  44.   __enumeral_type_class,
  45.   __boolean_type_class,
  46.   __pointer_type_class,
  47.   __reference_type_class,
  48.   __offset_type_class,
  49.   __real_type_class,
  50.   __complex_type_class,
  51.   __function_type_class,
  52.   __method_type_class,
  53.   __record_type_class,
  54.   __union_type_class,
  55.   __array_type_class,
  56.   __string_type_class,
  57.   __set_type_class,
  58.   __file_type_class,
  59.   __lang_type_class
  60. };
  61.  
  62. /* Return whether a type is passed by reference.  */
  63. #define __va_by_reference_p(TYPE) (sizeof (TYPE) > 8)
  64.  
  65. #define va_arg(AP,TYPE)                            \
  66. __extension__ (*({                            \
  67.   register TYPE *__ptr;                            \
  68.                                     \
  69.   if (__va_by_reference_p (TYPE))                    \
  70.     {                                    \
  71.       __ptr = *(TYPE **)(void *) (AP);                    \
  72.       (AP) = (__gnuc_va_list) ((char *) (AP) + sizeof (void *));    \
  73.     }                                    \
  74.   else                                    \
  75.     {                                    \
  76.       __ptr = (TYPE *)(void *)                        \
  77.         ((char *) (AP) + (sizeof (TYPE) < __va_rounded_size (char)    \
  78.               ? __va_rounded_size (TYPE) - sizeof (TYPE)    \
  79.               : 0));                    \
  80.       (AP) = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)); \
  81.     }                                    \
  82.                                     \
  83.   __ptr;                                \
  84. }))
  85.  
  86. #endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
  87.